<template>
  <div class="property-panel">
    <div class="title">工序属性</div>
    <div class="title-sub">{{ processDetail.workProcedureName || "" }}</div>
    <div class="item-title first-process">
      <div class="first-process-title">一级工序:</div>
      <div>{{ processDetail?.parent?.workProcedureName || "" }}</div>
    </div>
    <div class="property-content">
      <!-- 关联设备 -->
      <div class="item-title">
        <span>关联设备类型</span>
      </div>
      <template v-if="processDetail.types && processDetail.types.length">
        <div v-for="equip in processDetail.types" :key="equip.id" class="item">
          <span>{{ equip.deviceTypeName }}</span>
        </div>
      </template>

      <!-- 关联岗位 -->
      <div class="item-title">
        <span>关联岗位</span>
      </div>
      <template v-if="processDetail.stations && processDetail.stations.length">
        <div
          v-for="station in processDetail.stations"
          :key="station.id"
          class="item"
        >
          <span>{{ station.stationName }}</span>
        </div>
      </template>
    </div>
  </div>
</template>
<script>
import { getProcedure } from "@/api/technology/procedure";
export default {
  props: {
    nodeId: {
      type: [String, Number],
      default: "",
    },
  },
  data() {
    return {
      processDetail: null,
    };
  },
  methods: {
    getDetail(id) {
      getProcedure(id).then((response) => {
        this.processDetail = response.data;
        // 获取一级工序信息
        if (response.data.parentNo) {
          getProcedure(response.data.parentNo).then((res) => {
            this.processDetail.parent = res.data;
          });
        }
      });
    },
    // 设备列表关闭，赋值
    handleEquipListClose(list) {
      this.equipList = list;
      this.updateEquipProperties();
    },
    // 删除设备按钮操作
    handleDeleteEquip(equip) {
      this.equipList = this.equipList.filter((ele) => ele.id != equip.id);
      this.updateEquipProperties();
    },
  },
  watch: {
    nodeId: {
      handler(newVal) {
        if (newVal) {
          this.getDetail(newVal);
        } else {
          this.processDetail = null;
        }
      },
      immediate: true,
    },
  },
};
</script>
<style lang="scss" scoped>
.property-panel {
  position: absolute;
  right: 0;
  top: 33px;
  width: 200px;
  height: calc(100% - 40px);
  z-index: 10;
  background: #ffffff;
  padding: 4px 10px 10px;
  .title {
    height: 40px;
    line-height: 40px;
    font-weight: 600;
    text-align: center;
    border-color: #a5a5a5;
  }
  .title-sub {
    text-align: center;
    color: #999;
    line-height: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .item-title {
    line-height: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    // font-weight: 600;
  }
  .first-process {
    display: flex;
    justify-content: space-between;
    // font-weight: 600;
    flex-wrap: nowrap;
    align-items: flex-start;
    .first-process-title {
      flex: none;
      margin-right: 10px;
    }
  }
  .property-content {
    height: calc(100% - 40px - 24px);
    overflow: auto;
    /* 整个滚动条 */
    &::-webkit-scrollbar {
      /* 对应纵向滚动条的宽度 */
      width: 5px;
      /* 对应横向滚动条的宽度 */
      height: 5px;
    }

    /* 滚动条上的滚动滑块 */
    &::-webkit-scrollbar-thumb {
      background-color: #d1d1d1;
      border-radius: 5px;
    }

    /* 滚动条轨道 */
    &::-webkit-scrollbar-track {
      background-color: #f5f5f5;
      border-radius: 5px;
    }
  }
  .item {
    width: 100%;
    text-align: center;
    height: 28px;
    line-height: 28px;
    margin-right: 10px;
    margin-bottom: 10px;
    padding: 0 10px;
    font-size: 14px;
    display: inline-block;
    vertical-align: middle;
    background: #eaf8fe;
    color: #409eff;
  }
  .del-item-btn {
    margin-left: 10px;
    cursor: pointer;
  }
}
</style>
